package servlet.recipe.page;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import servlet.account.control.InfoCheck;
import servlet.recipe.control.Recipe_rsp;

import java.io.IOException;

@WebServlet("/New")
public class New extends HttpServlet {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            InfoCheck ifc=new InfoCheck();
            if (ifc.checkCredentials(req)){req.setAttribute("Login","Session");}
            req.setAttribute("title","最新菜谱");
            Recipe_rsp rsq=new Recipe_rsp();
            req.setAttribute("recipes",rsq.cheackRecipesNull(rsq.recipes_rsp(1,null)));
            req.getRequestDispatcher("chushi/jsp/select.jsp").forward(req,resp);
        }

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            doGet(req, resp);
        }
}
